package com.xd.clap.utils.convenient;

import cn.hutool.core.util.ObjectUtil;
import com.xd.clap.commons.SystemConstant;


import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 * @description pk_id验证
 * @author guanxiangfeng
 * @date 2023/4/18 17:29
 * @params 
 * @return 
 */
public class IsPkIdValidation implements ConstraintValidator<IsPkId, Long> {
    @Override
    public void initialize(IsPkId constraintAnnotation) {
        ConstraintValidator.super.initialize(constraintAnnotation);
    }

    @Override
    public boolean isValid(Long pkId, ConstraintValidatorContext constraintValidatorContext) {
        if (ObjectUtil.isEmpty(pkId) || pkId.toString().length() != SystemConstant.NUM_19) {
            return false;
        }
            return true;
    }

}
